<!-- Modal -->
<div class="modal-dialog" style="width: 450px;">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel2">选择机构</h4>
        </div>
        <div class="modal-body" style="height: 400px; overflow-y: auto">
            <div class="dd" id="nestable3">



            <#if organizationsTable??>
                <#list organizationsTable as organization>
                    <ol class="dd-list">
                        <#if orgId?? && orgId == organization.orgId!''>
                            <li class="dd-item dd3-item dd-field dd-active" data-id="5">
                                <div class="dd3-content">${organization.orgName!''}
                                    <input type="hidden" value="${organization.orgId!''}" name="id"/>
                                    <input type="hidden" value="${organization.orgName!''}" name="orgName"/>
                                </div>
                                <#if organization.childrenOrgList??>
                                    <#assign organizationsTable=organization.childrenOrgList/>
                                    <#include "orgTree.ftl"/>
                                </#if>
                            </li>
                        <#else>
                            <li class="dd-item dd3-item dd-field" data-id="5">
                                <div class="dd3-content">${organization.orgName!''}
                                    <input type="hidden" value="${organization.orgId!''}" name="id"/>
                                    <input type="hidden" value="${organization.orgName!''}" name="orgName"/>
                                </div>
                                <#if organization.childrenOrgList??>
                                    <#assign organizationsTable=organization.childrenOrgList/>
                                    <#include "orgTree.ftl"/>
                                </#if>
                            </li>
                        </#if>
                    </ol>
                </#list>
            </#if>

            </div>
        </div>
        <form class="form-horizontal" role="form" id="search_assign_menu_table" method="post"
              action="${absoluteContextPath}/system/organization/goSelectOrg">
            <input type="hidden" id="actionType" name="actionType" value="${actionType!''}"/>
        </form>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">取消</button>
            <button id="confirm" type="button" class="btn btn-primary">确定</button>
        </div>
    </div>
</div>
<script>

    $(function () {
        var updateOutput = function (e) {
            var list = e.length ? e : $(e.target);
            output = list.data('output');
            if (window.JSON) {
                $(output).val(window.JSON.stringify(list.nestable('serialize')));//, null, 2));
            } else {
                output.val('JSON browser support required for this demo.');
            }
        };
        $('#nestable3').nestable({
            group: 1
        }).on('change', updateOutput);
        $('.dd3-content .controls a').tooltip();
        $('.dd3-content .dropdown-menu input').click(function (e) {
            e.preventDefault();
            e.stopPropagation();
        });

        $(".dd-list li").click(function (e) {
            if ($(e.target).attr("class") != "dd3-content") {
                return;
            }
            if ($(this).attr("class").indexOf('dd-active') > 0) {
                $(".dd-list li").each(function () {
                    $(this).removeClass("dd-active");
                    $(this).find("li").removeClass("dd-active");
                });
            } else {
                $(".dd-list li").each(function () {
                    $(this).removeClass("dd-active");
                    $(this).find("li").removeClass("dd-active");
                });
                $(this).addClass("dd-active");
            }
            e.preventDefault();
            e.stopPropagation();
        });
    });
</script>